Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes fetchone()/cursor iteration failures on ODBC catalog result sets (e.g., tables(), columns(), etc.) by ensuring row-tracking state is initialized when preparing metadata result sets, and adds regression tests covering fetchone() and iteration across several catalog methods (GH-505 / AB#43996).
Changes:
- Initialize catalog result-set row tracking by resetting cursor rownumber state in
_prepare_metadata_result_set(). - Add catalog-method regression tests for
fetchone()and iterator behavior, plus rownumber increment assertions. - Add SQL setup/cleanup for catalog test objects (schema + tables with PK/FK).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
mssql_python/cursor.py |
Resets rownumber tracking when preparing catalog/metadata result sets so fetchone() and iteration treat them as active result sets. |
tests/test_004_cursor.py |
Adds regression tests for catalog fetchone()/iteration + rownumber increments and introduces schema/table setup & cleanup for these tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 67.8%
mssql_python.row.py: 70.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 74.3%
mssql_python.pybind.connection.connection.cpp: 75.8%
mssql_python.__init__.py: 77.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 85.2%🔗 Quick Links
|
sumitmsft
previously approved these changes
Apr 21, 2026
… jahnvi/fetchone_issue
sumitmsft
previously approved these changes
Apr 21, 2026
bewithgaurav
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request improves the reliability and correctness of catalog result set iteration in the
mssql_pythonpackage. It ensures that therownumberattribute is properly initialized for catalog queries, and adds comprehensive tests to verify thatfetchone()and iteration work as expected for various catalog methods (such astables,columns,primaryKeys, etc.).Catalog result set iteration and row tracking improvements:
rownumberattribute is reset and properly initialized when fetching catalog results, so thatfetchone()and iteration over catalog queries work correctly. (mssql_python/cursor.py)Testing enhancements for catalog queries:
fetchone()and iteration work as expected for catalog-related cursor methods, includingtables,columns,primaryKeys,foreignKeys,statistics,procedures,rowIdColumns,rowVerColumns, andgetTypeInfo. These tests also verify thatrownumberincrements correctly and that no errors are raised when expected. (tests/test_004_cursor.py)tests/test_004_cursor.py)